{% extends 'dashboard/base.html' %}

{% block body %}
<script type="text/javascript">

    $("#checkAll").change(function () {
        $("input:checkbox").prop('checked', $(this).prop("checked"));
    });
    $(document).ready(function() {
        $('.btn-danger').click(function(){
            if (confirm('Are you sure you want to delete this?')) {
                var scan_id = ['a7af5b68-b661-45ad-90fd-ffa27526cdce'];
                $.each($("input[name='del_scan_id']:checked"), function(){
                    scan_id.push($(this).val());
                });

                var json_scanid = scan_id.join(", ");
                $.ajax({
                    type:'POST',
                    <!--contentType: 'application/json; charset=utf-8',-->
                    url:'{% url 'staticscanners:scan_delete' %}',
                    data:{
                       scan_id: json_scanid,
                       csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val()
                    },
                    sucess:function(){

                    }
                });
                setTimeout(function(){location.reload();},1200);
            }
        });

    });

</script>

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <div class="float-right">
                           {% if user.is_superuser == True or user.role.id == 2 %}
                            <div class="btn-group" role="group" aria-label="Basic example">
                                <a href="{% url 'report_upload:upload' %}" class="btn btn-primary btn-mini" data-toggle="tooltip" data-placement="top" title="Upload Report"><i
                                        class="fas fa-upload
"></i> Upload</a>
                            </div>
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                            {% endif %}
                        </div>
                        <br>
                        <br>
                        <br>
                        <div class="d-md-flex align-items-center">
                            <h1 class="card-title">SAST Scans List</h1>
                        </div>
                        <br>
                        <div class="row">
                            <div class="table-responsive">
                                <table id="bandit_scan_list" class="table table-bordered data-table">
                            <thead>
                            <tr>
                                <th><label class="customcheckbox m-b-20">
                                <input type="checkbox" id="mainCheckbox">
                                <span class="checkmark"></span>
                                </label></th>
                                <th>Project Name</th>
                                <th>Scanner</th>
{#                                <th>Status</th>#}
                                <th>Date Time</th>
                                <th>Total</th>
                                <th>High</th>
                                <th>Medium</th>
                                <th>Low</th>
                                <th>Duplicates</th>
                            </tr>
                            </thead>
                            <tbody>{% for data in all_scans %}
                            <tr data-target="#">
                                <td>{% csrf_token %}
                                            <form>
                                                <label class="customcheckbox">
                                                    <input type="checkbox" class="listCheckbox"
                                                           value="{{data.scan_id}}"
                                                           name="del_scan_id"
                                                           onClick="reload">
                                                    <span class="checkmark"></span>
                                                </label>
                                            </form>
                                        </td>
                                <td>
                                    <a href="{% url 'staticscanners:list_vuln' %}?scan_id={{data.scan_id}}&scanner={{ data.scanner }}">{% firstof data.project_name 'None' %}</a>
                                </td>
                                 <td>{% if data.scanner == 'Dependencycheck' %}

                                        <div class="p-1"><img src="/static/tools/dependencycheck.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Dependencycheck"></div></td>{% elif data.scanner == 'Checkmarx' %}
                                     <div class="p-1"><img src="/static/tools/checkmarx.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Checkmarx"></div></td>{% elif data.scanner == 'Findbugs' %}
                                     <div class="p-1"><img src="/static/tools/findbugs.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Findbugs"></div></td>{% elif data.scanner == 'Bandit' %}
                                     <div class="p-1"><img src="/static/tools/bandit.jpeg" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Bandit"></div></td>{% elif data.scanner == 'Clair' %}
                                     <div class="p-1"><img src="/static/tools/clair.svg" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Clair"></div></td>{% elif data.scanner == 'Trivy' %}
                                     <div class="p-1"><img src="/static/tools/trivy.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Trivy"></div></td>{% elif data.scanner == 'Npmaudit' %}
                                      <div class="p-1"><img src="/static/tools/npmaduit.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Npmaudit"></div></td>{% elif data.scanner == 'Nodejsscan' %}
                                     <div class="p-1"><img src="/static/tools/nodejs.jpeg" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Nodejsscan"></div></td>{% elif data.scanner == 'Tfsec' %}
                                     <div class="p-1"><img src="/static/tools/tfsec.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Tfsec"></div></td>{% elif data.scanner == 'Whitesource' %}
                                     <div class="p-1"><img src="/static/tools/whitesource.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Whitesource"></div></td>
                                 {% elif data.scanner == 'Twistlock' %}
                                     <div class="p-1"><img src="/static/tools/twistlock.png" alt="user" width="30"
                                                                 class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Twistlock"></div></td>
                                     {% elif data.scanner == 'Semgrep' %}
                                     <div class="p-1"><img src="/static/tools/semgrep.svg" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Semgrep"></div></td>
                                     {% elif data.scanner == 'Brakeman' %}
                                     <div class="p-1"><img src="/static/tools/brakeman.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Brakeman"></div></td>
                                     {% elif data.scanner == 'Gitlabsca' %}
                                     <div class="p-1"><img src="/static/tools/gitlab.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Gitlabsca"></div></td>
                                      {% elif data.scanner == 'Gitlabsast' %}
                                     <div class="p-1"><img src="/static/tools/gitlab.png" alt="user" width="30"
                                                                  class="rounded-circle" data-toggle="tooltip" data-placement="top" title="Gitlabsast"></div></td>
                                 {% endif %}

{#                                <td width="20%">#}
{#                                            <div>#}
{#                                                <div class="d-flex no-block align-items-center">#}
{#                                                    <span>{{data.scan_status}}{{data.vul_status}}% Completed</span>#}
{#                                                </div>#}
{#                                                <div class="progress{% if data.scan_status != '100.0' %} active progress-striped{% endif %}">#}
{#                                                    <div class="progress-bar progress-bar-striped" role="progressbar"#}
{#                                                         style="width: {{data.scan_status}}{{data.vul_status}}%" aria-valuenow="10" aria-valuemin="0"#}
{#                                                         aria-valuemax="100"></div>#}
{#                                                </div>#}
{#                                            </div>#}
{#                                        </td>#}
                                <td>{{data.date_time}}</td>
                                <td><span class="badge badge-pill badge-dark">{{data.total_vul}}</span></td>
                                <td><span class="badge badge-pill badge-danger">{{data.high_vul}}</span></td>
                                <td><span class="badge badge-pill badge-warning">{{data.medium_vul}}</span></td>
                                <td><span class="badge badge-pill badge-info">{{data.low_vul}}</span></td>
                                <td><span class="badge badge-pill badge-danger">{{data.total_dup}}</span></td>
                            </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
{% endblock %}